#!/usr/bin/env node

const http = require('http');
http.createServer((req,res)=>{
  if(req.url = '/'){

    let buf = Buffer.from('<html><body><h1>hello</h1></body></html>');
    res.setHeader('Content-Type','text/html');
    res.setHeader('Content-Length',`${buf.byteLength}`);
    res.end(html);

  }else{
    res.statusCode = 404;//变换状态码，使用statusCode
    res.end('Ok!');//响应体
  }

}).listen(3000);
